﻿using System;
using System.ComponentModel;
using Fuse8.GlobalizationFramework.BusinessServices;

namespace Fuse8.GlobalizationFramework.MvcPowered.Attributes
{
    /// <summary>
    /// Specifies display text for property
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    public class LocalizedDisplayNameAttribute : DisplayNameAttribute
    {
        /// <summary>
        /// Initializes attribute by resource key
        /// </summary>
        /// <param name="resourceKey">Resource key</param>
        public LocalizedDisplayNameAttribute(string resourceKey)
        {
            DisplayNameValue = ResourceService.FindValue(resourceKey);
        }

        /// <summary>
        /// Initializes attribute by resource key and default value
        /// </summary>
        /// <param name="resourceKey">Resource key</param>
        /// <param name="defaultValue">Default value</param>
        public LocalizedDisplayNameAttribute(string resourceKey, string defaultValue)
        {
            DisplayNameValue = ResourceService.FindValue(resourceKey, defaultValue);
        }                 
    }
}